package org.cllib.ds;

public class Node {
	Node parent , left , right;
	Object data;
	
	public final static int SIDE_UNKNOWN = -1;
	
	public final static int SIDE_LEFT = 0;
	public final static int SIDE_RIGHT = 1;
	public final static int SIDE_PARENT = 2;
	public Node getParent() {
		return parent;
	}
	public void setParent(Node parent) {
		this.parent = parent;
	}
	public Node getLeft() {
		return left;
	}
	public void setLeft(Node left) {
		this.left = left;
	}
	public Node getRight() {
		return right;
	}
	public void setRight(Node right) {
		this.right = right;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public int side(){
		if(getParent().getLeft() == this){
			return SIDE_LEFT;
		}else if(getParent().getRight() == this){
			return SIDE_RIGHT;
		}else if(getParent() == this){
			return SIDE_PARENT;
		}
		
		return SIDE_UNKNOWN;
	}
}
